package com.verisette.ncos.service.master.bizunit;

import java.util.HashMap;
import java.util.List;

import org.apache.log4j.Logger;

import org.corp.agi.common.exception.ProcessException;
import org.corp.agi.service.bean.ProcessContext;
import org.corp.agi.service.bizunit.CommonBusinessUnit;
import com.verisette.ncos.persistence.domain.MasterUserProfile;

/**
 * {Description here}
 *
 * @author Thippawan Muangchu (Tip)
 * @since Apr 8, 2010 1:52:15 PM
 * @version 1.0.0
 * @see 
 */
public class LoadUserNameBU extends CommonBusinessUnit {
	private Logger logger = Logger.getLogger(LoadUserNameBU.class);

	@Override
	public void execute(ProcessContext processContext) throws ProcessException {
		StringBuffer sb = new StringBuffer();
		HashMap<Integer, String> map = new HashMap<Integer, String>();
		
		//select USP_ID, USP_USER_NAME
		sb.append("SELECT * FROM MASTER_USER_PROFILE");
		List<MasterUserProfile> list = (List<MasterUserProfile>) commonDAO.nativeQuery(sb.toString(), MasterUserProfile.class);
		
		//loop put result to map
		for(int i=0;i<list.size();i++){
			map.put(list.get(i).getUspId(), list.get(i).getUspUserName());
		}
		
		//set map to value object
		processContext.setValueObject(list);
	}
	
}
